#include "mainwindow.h"
#include <QGraphicsScene>
#include <QMouseEvent>


MainWindow::MainWindow(QWidget *parent) :
    QGraphicsView(parent)
{
    scene = new QGraphicsScene();
    scene->setSceneRect(0, 0, 500, 500);
    setFixedSize(500,500);
    setScene(scene);
    setRenderHint(QPainter::Antialiasing);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}

MainWindow::~MainWindow()
{
    delete scene;
}

void MainWindow::mousePressEvent(QMouseEvent *mouseButton)
{
    if(mouseButton->button() == Qt::LeftButton)
    {
            scene->addEllipse(mouseButton->x(),mouseButton->y(),20,20,QPen(Qt::black),QBrush(Qt::blue));
    }
    else if(mouseButton->button() == Qt::RightButton)
    {
            scene->addRect(mouseButton->x(),mouseButton->y(),30,30, QPen(Qt::black),QBrush(Qt::red));
    }
}


